<template>
	<view>
		
		<u-tabbar :value="current?current:1" @change="changeTab" :fixed="true"
				  :safeAreaInsetBottom="true" :border="true" :placeholder="true" activeColor="#e82f3c">
			<u-tabbar-item v-for="(item,index) in list" :key="index" :name="item.id" :text="item.text">
				<image class="u-page__item__slot-icon" slot="active-icon" :src="item.selectedIconPath"></image>
				<image class="u-page__item__slot-icon-index" slot="inactive-icon" :src="item.iconPath"></image>
			</u-tabbar-item>
		</u-tabbar>
		
	</view>
</template>

<script>
	export default {
		name:"tabbar",
		data() {
			return {
				list: [
					{
						id: 1,
						selectedIconPath: "../../static/tabbarImg/tab1-selected.png",
						iconPath: "../../static/tabbarImg/tab1.png",
						text: '首页',
						pagePath: "pages/index/index"
					},
					{
						id: 2,
						selectedIconPath: "../../static/tabbarImg/tab2-selected.png",
						iconPath: "../../static/tabbarImg/tab2.png",
						text: '急救电话',
						pagePath: "pages/phone/phone"
					},
					{
						id: 3,
						selectedIconPath: "../../static/tabbarImg/tab3-selected.png",
						iconPath: "../../static/tabbarImg/tab3.png",
						text: '我的',
						pagePath: "pages/mine/mine"
					}
				],
			};
		},
		props: {
			current: {
				type: Number,
				default: 1
			}
		},
		methods: {
			changeTab(e) {
				// if(e == 2){
				// 	uni.makePhoneCall({
				// 		phoneNumber: '120'
				// 	});
				// 	return
				// }
				uni.switchTab({
					url: '/' + this.list[e-1].pagePath,
				})
			}
		}
	}
</script>

<style scoped>
.u-page__item__slot-icon{
        width: 21px!important;
        height: 21px!important;
    }
	
.u-page__item__slot-icon-index{
		width: 20px!important;
		height: 20px!important;
	}
</style>
